package com.czy;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class 倒转文本 {
    public static void main(String[] args) throws IOException {
        File file = new File("C:\\Users\\Administrator\\OneDrive\\Desktop\\新建 文本文档 (2).txt");
        BufferedReader br = new BufferedReader(new FileReader(file));
        List<String> list = new ArrayList<>();
        String s;
        while ((s = br.readLine()) != null) {
            list.add(s);
        }
        br.close();
        list = list.reversed();
        for (String string : list) {
            if(string == null || string.isBlank()) {
                System.out.println();
                continue;
            }
            string = string.substring(0, !string.contains(" czy ") ? string.length() : string.indexOf(" czy "));
            System.out.println(string);
        }
    }
}
